package com.study.hot.jetpack.demo_shopping

import android.os.Bundle
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import androidx.navigation.fragment.NavHostFragment
import androidx.navigation.ui.setupWithNavController
import com.study.hot.R
import kotlinx.android.synthetic.main.main_activity.*

/**
 * <pre>
 *     author : fauks
 *     time   : 2020/03/27
 *     desc   :
 * </pre>
 */
class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.main_activity)

        val navFragment: NavHostFragment = supportFragmentManager.findFragmentById(R.id.main_nav_host_fragment) as NavHostFragment
        //获取NavController
        val navController = navFragment.navController
        mainBottomView.setupWithNavController(navController)
        navController.addOnDestinationChangedListener { controller, destination, arguments ->
            when (destination.id) {
                R.id.meFragment -> cameraIv.visibility = View.VISIBLE
                else -> cameraIv.visibility = View.GONE
            }

        }
    }
}